<template>
  <div class="box">
    <header class="header">
      <router-link tag="div" to="/" class="iconfont icon-zuojiantou1"></router-link>
      <router-link tag="div" to="/search" class="iconfont icon-sousuo1"><input type="text" v-model="val" autofocus placeholder="输入菜谱名、食材名"></router-link>
      <div @click="goSearchList(val)" class="iconfont icon-sousuo"></div>
    </header>
    <div class="content">
      <p>热门搜索</p>
      <ul class="hotSearch">
        <li @click="search">麻婆豆腐</li>
        <li @click="search">香蕉班戟卷</li>
        <li @click="search">黄桃班戟</li>
        <li @click="search">圣诞颂歌</li>
        <li @click="search">酸奶</li>
        <li @click="search">黑椒牛排</li>
        <li @click="search">白萝卜</li>
        <li @click="search">雪花酥</li>
      </ul>
    </div>
  </div>
</template>

<script>
// import Prolist from '@/components/Prolist'
import Vue from 'vue'
import { Swipe, SwipeItem } from 'mint-ui'
// import api from '@/api'
import axios from 'axios'
Vue.use(Swipe, SwipeItem)
export default {
  data () {
    return {
      searchlist: [],
      val: ''
    }
  },
  created () {
    // axios.all([this.getSearchList()])
    //   .then(axios.spread((searchData) => {
    //     console.log(searchData)
    //     let arr = []
    //     // searchData.data.map(item => {
    //     //   arr.push('/daxun/' + item)
    //     // })
    //     this.bannerlist = arr
    //   }))
  },
  methods: {
    search: function (event) {
      var el = event.currentTarget
      this.val = el.innerText
    },
    goSearchList (val) {
      // console.log(val)
      sessionStorage.setItem('search', val)
      this.$router.push(`/searchlist?grename=${this.val}`)
    }
  }
}
</script>

<style lang="scss" scoped>
@import '@/lib/reset.scss';
.header {
  @include flexbox();
  align-items: center;
  justify-content: space-between;
  padding: 0 0.1rem;
  border-bottom: 1px solid #ccc;
  .iconfont {
    input {
      border: 0;
      margin-left: 5px;
      background-color: #F7F7F7;
      width: 90%;
      color: rgb(128, 184, 151);
    }
  }
  .icon-fenlei1 {
    @include font-size(0.20rem);
  }
  .icon-sousuo1 {
    background: #F7F7F7;
    padding: 5px 10px;
    width: 85%;
    border-radius: 5px;
    color: #CCCCCC;
    @include font-size(0.15rem);
  }
  .icon-lingdangcopy {
    @include font-size(0.20rem);
  }
}

.kinds {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-around;
  // flex: 1;
  .iconfont {
    font-size: 22px;
    color: #31DBC8;
  }
  li {
    width: 24%;
    height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    span {
      font-size: 14px;
      color: rgb(82, 80, 80);
    }
  }
}
.content{
  width: 90%!important;
  margin: 20px auto 0;
  p {
    font-weight: 700;
  }
  .hotSearch {
    display: flex;
    flex-wrap: wrap;
    li {
      border: 1px solid #E6E6E6;
      border-radius: 5px;
      padding: 5px;
      margin: 10px 10px 10px 0;
    }
  }
}
</style>
